#ifndef PAINTEDBUTTON_H
#define PAINTEDBUTTON_H

class PaintedButton;

#include "Utilities.h"
#include "common.h"

class DLL PaintedButton
{
public:
	enum GradientMode
	{
		Vertical,
		Horizontal
	};

	typedef void (*PBEVENTPROC)(PaintedButton* sender, LPVOID tag);

	PaintedButton(HWND parentWindow);
	~PaintedButton();

	bool HandleWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
	void HandlePainting(HDC hdc);
	
	void Clicked(PBEVENTPROC ptr);
	void MouseLeave(PBEVENTPROC ptr);
	void MouseEnter(PBEVENTPROC ptr);
	void RightMouseButtonUp(PBEVENTPROC ptr);
	void Hide();
	void Show();
	bool IsVisible();
	HWND GetParentWindow();
	tstring GetText();
	void SetText(tstring text, int leftPadding = 0, int topPadding = 0, int rightPadding = 0, int bottomPadding = 0);
	DWORD GetTextFormat();
	void SetTextFormat(DWORD format);
	COLORREF GetTextColor();
	void SetTextColor(COLORREF cr);
	int GetFontSize();
	void SetFontSize(int size);
	int GetFontWeight();
	void SetFontWeight(LONG weight);
	GradientMode GetGradientMode();
	void SetGradientMode(GradientMode mode);
	RECT GetBounds();
	void SetBounds(RECT value);
	void SetBounds(LONG left, LONG top, LONG right, LONG bottom);
	SIZE GetSize();
	void SetSize(SIZE value);
	void SetSize(LONG cx, LONG cy);
	POINT GetLocation();
	void SetLocation(POINT value);
	void SetLocation(LONG x, LONG y);	
	LPVOID GetTag();
	void SetTag(LPVOID lpVoid);
	bool GetCheckable();
	void SetCheckable(bool value);
	bool GetChecked();
	void SetChecked(bool value);
	void PerformClick();
	void Refresh();

private:
	void CallPBEvent(PBEVENTPROC ptr);

	PBEVENTPROC onClickPtr;
	PBEVENTPROC onMouseLeavePtr;
	PBEVENTPROC onMouseEnterPtr;
	PBEVENTPROC onRightMouseButtonUpPtr;
	COLORREF textColor;
	HWND parentHWnd;
	RECT bounds;
	tstring text;
	bool visible;
	bool checkable;
	bool buttonHover;
	bool buttonChecked;
	GradientMode gradientMode;
	LPVOID tag;
	RECT textPadding;
	DWORD textFormat;
	DWORD fontSize;
	DWORD fontWeight;
};

#endif